classdef ModelParser < exception.Exception
    enumeration
        AUTOEXOGENIZE_INVALID_DEFINITION ( ...
            'error', ...
            'Invalid !autoexogenize definition: %s ' ...
            )
        AUTOEXOGENIZE_MUTLIPLE_SHOCK ( ...
            'error', ...
            [ 'This shock is included in more than one ' ...
            '!autoexogenize definition: %s ' ] ...
            )
        PREFIX_MULTIPLIER ( ...
            'error', ...
            [ 'Prefix ''%s'' is reserved for lagrange multipliers ', ...
            'in optimal policy models; change this name: %s ' ] ...
            )
        LOSS_FUNC_DISCOUNT_EMPTY ( ...
            'error', ...
            'Loss function discount factor is empty' ...
            )
        MULTIPLE_LOSS_FUNC ( ...
            'error', ...
            'Multiple loss functions found in model file' ...
            )
        MISPLACED_TIME_SUBSCRIPT ( ...
            'error', ...
            'Misplaced or invalid time subscript in this equation: %s' ...
            )
        MISPLACED_STEADY_REFERENCE ( ...
            'error', ... 
            'Misplaced or invalid steady-state reference in this equation: %s ' ...
            )
        STD_CORR_IN_OTHER_THAN_LINK ( ...
            'error', ...
            'Std or corr names cannot be used in equations other than dynamic links: %s ' ...
            )
        UNDECLARED_MISTYPED_NAME ( ...
            'error', ...
            'Undeclared or mistyped name ''%s'' in this equation: %s ' ...
            )
        SSTATE_REF_IN_LINEAR ( ...
            'error', ...
            'Steady-state references not allowed in linear models: %s ' ...
            )
        SSTATE_REF_IN_DTREND ( ...
            'error', ...
            'Steady-state references not allowed in dtrend equations: %s ' ...
            )
        SSTATE_REF_IN_LINK ( ...
            'error', ...
            'Steady-state references not allowed in dynamic links: %s ' ...
            )            
        NAME_CANNOT_BE_NONNEGATIVE ( ...
            'error', ...
            'This name cannot be declared as nonnegative: %s ' ...
            )
        DYNAMIC_EQUATION_EMPTY ( ...
            'error', ...
            'Dynamic part of this equation is empty: %s ' ...
            )
        LHS_VARIABLE_MUST_LOG_IN_DTREND ( ...
            'error', ...
            'The LHS variable must be in log in this dtrend equation: %s ' ...
            )
        MULTIPLE_LHS_DTREND ( ...
            'error', ...
            'Mutliple dtrend equations for this measurement variable: %s ' ...
            )
        INVALID_LHS_DTREND ( ...
            'error', ...
            'Invalid LHS in this dtrend equation: %s ' ...
            )
        INVALID_LHS_LINK ( ...
            'error', ...
            'Invalid LHS in this dynamic link: %s ' ...
            )
        INVALID_LHS_UPDATE ( ...
            'error', ...
            'Invalid LHS in this parameter update equation: %s ' ...
            )
        MEASUREMENT_SHIFT ( ...
            'error', ...
            'Lag or lead of measurement variable(s) in this equation: %s ' ...
            )
        SHOCK_SHIFT ( ...
            'error', ...
            'Lag or lead of shock(s) in this equation: %s ' ...
            )        
        PARAMETER_SHIFT ( ...
            'error', ...
            'Lag or lead of parameter(s) in this equation: %s ' ...
            )     
        MEASUREMENT_VARIABLE_IN_TRANSITION ( ...
            'error', ...
            'Measurement variable(s) in this transition equation: %s ' ...
            )     
        LEAD_OF_TRANSITION_IN_MEASUREMENT ( ...
            'error',...
            'Lead(s) of transition variable(s) in this measurement equation: %s ' ...
            )
        NO_CURRENT_MEASUREMENT ( ...
            'error', ...
            [ 'No current dated measurement variable ', ...
            'in this measurement equation: %s ' ] ...
            )
        TRANSITION_SHOCK_IN_MEASUREMENT ( ...
            'error', ...
            'This measurement equation has transition shock(s): %s ' ...
            )
        MEASUREMENT_SHOCK_IN_TRANSITION ( ...
            'error', ...
            'This transition equation has measurement shock(s): %s ' ...
            )
        OTHER_THAN_PARAMETER_EXOGENOUS_IN_DTREND ( ...
            'error', ...
            [ 'RHS of this dtrend equation has names other than ', ...
            'parameters or exogenous variables: %s ']  ...
            )
        EXOGENOUS_IN_OTHER_THAN_DTREND ( ...
            'error', ...
            'Exogenous variables allowed only in dtrend equations: %s ' ...
            )
        NO_TRANSITION_VARIABLE ( ...
            'error', ...
            'No transition variable found in model file' ...
            )
        NO_TRANSITION_EQUATION ( ...
            'error', ...
            'No transition equation found in model file' ...
            )
        NO_CURRENT_DATE_IN_DYNAMIC ( ...
            'error', ...
            'No current date for this variable in dynamic equations: %s ' ...
            )
        NO_CURRENT_DATE_IN_STEADY ( ...
            'error', ...
            'No current date for this variable in steady equations: %s ' ...
            )
        NO_TRANSITION_VARIABLE_IN_DYNAMIC ( ...
            'error', ...
            'No transition variable in this dynamic equation: %s ' ...
            )
        NO_TRANSITION_VARIABLE_IN_STEADY ( ...
            'error', ...
            'No transition variable in this steady equation: %s ' ...
            )
        NO_MEASUREMENT_VARIABLE_IN_DYNAMIC ( ...
            'error', ...
            'No measurement variable in this dynamic equation: %s ' ...
            )
        NO_MEASUREMENT_VARIABLE_IN_STEADY ( ...
            'error', ...
            'No measurement variable in this steady equation: %s ' ...
            )
        NUMBER_TRANSITION_EQUATIONS_VARIABLES ( ...
            'error', ...
            [ 'Number of transition equations [%g] does not match ', ...
            'number of transition variables [%g]' ] ...
            )
        NUMBER_MEASUREMENT_EQUATIONS_VARIABLES ( ...
            'error', ...
            [ 'Number of measurement equations [%g] does not match ', ...
            'number of measurement variables [%g]' ] ...
            )
    end
    
    
    
    
    properties (Constant)
        CLASS_IDENTIFIER = 'Model';
        MODEL_PARSER_HEADER_FORMAT = ' when parsing %s ';
        MODEL_PARSER_HEADER_EMPTY_FORMAT = ' when parsing input string';
    end
    
    
    
    
    methods
        function header = createHeader(this)
            header = createHeader@exception.Exception(this);
            fileName = exception.ModelParser.storeFileName( );
            if ~isempty(fileName)
                addHeader = sprintf( ...
                    exception.ModelParser.MODEL_PARSER_HEADER_FORMAT, ...
                    fileName ...
                    );
            else
                addHeader = exception.ModelParser.MODEL_PARSER_HEADER_EMPTY_FORMAT;
            end
            header = [ header, addHeader ];
        end
    end
    
    
    
    
    methods (Static)
        function varargout = storeFileName(varargin)
            persistent FILE_NAME;
            if nargout==0
                if nargin==0
                    FILE_NAME = '';
                else
                    FILE_NAME = varargin{1};
                end
            else
                if isempty(FILE_NAME) || ~ischar(FILE_NAME)
                    FILE_NAME = '';
                end
                varargout{1} = FILE_NAME;
            end
        end
    end
end
